package org.dromara.study.controller;

import org.dromara.common.core.domain.R;
import org.dromara.study.domain.entity.Skill;
import org.dromara.study.service.SkillService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import java.util.List;

@RestController
@RequestMapping("/skill")
public class SkillController {

    @Autowired
    private SkillService skillService;

    @PostMapping("/add")
    public R<String> add(@RequestBody Skill skill){
        skillService.save(skill);
        return R.ok("新增成功");
    }


    @PostMapping("/edit")
    public R<String> update(@RequestBody Skill skill){
        skillService.updateById(skill);
        return R.ok("编辑成功");
    }

    @GetMapping("/remove/{id}")
    public R<String> remove(@PathVariable("id") Long id){
        skillService.removeById(id);
        return R.ok("删除成功");
    }

    @GetMapping("/list")
    public R<List<Skill>> getList(Skill skill){
        return R.ok(skillService.list());
    }
}
